package com.jt.yygh.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jt.yygh.hospital.VO.HospitalSetsVO;
import com.jt.yygh.hospital.entity.hosp.HospitalSet;
import com.jt.yygh.hospital.mapper.HospitalSetMapper;
import com.jt.yygh.hospital.service.HospitalSetService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author jiang tao
 * @date 2022/2/11
 * @description:
 **/
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {

    @Override
    public Page<HospitalSet> getAllHospitalSetsByPage(String searchName, int pageNum, int pageSize) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.like("hosname",searchName);
        Page<HospitalSet> HospitalSetList = this.page(new Page<>(pageNum, pageSize),wrapper);
        return HospitalSetList;
    }

    @Override
    public Boolean addHospitalSetsVO(HospitalSetsVO hospitalSetsVO) {
        HospitalSet hospitalSet = new HospitalSet();
        BeanUtils.copyProperties(hospitalSetsVO, hospitalSet);
        hospitalSet.setCreateTime(new Date());
        hospitalSet.setUpdateTime(new Date());
        return  this.save(hospitalSet);
    }
}
